home *** CD-ROM | disk | FTP | other *** search
- #include <sockinet.h>
-
- extern "C" void exit(int);
-
- static int send_cmd(const char*, iosockstream&);
- static int get_text(istream&);
-
- main()
- {
- iosockinet sio(sockbuf::sock_stream);
- sockinetaddr sina("murdoch.acc.virginia.edu", "nntp", "tcp");
-
- sio->connect(sina);
-
- send_cmd(0, sio);
-
- send_cmd("HELP", sio); get_text(sio);
- send_cmd("QUIT", sio);
- }
-
- int send_cmd(const char* cmd, iosockstream& s)
- {
- s << cmd << "\r\n";
-
- char buf[256];
- s.getline(buf, 255);
-
- cout << buf << endl;
-
- if (buf[0] == '4' || buf[1] == '5') return 1;
- return 0;
- }
-
- int get_text(istream& s)
- {
- char buf[256];
- while (s.getline(buf, 255))
- if (buf[0] == '.') {
- if (buf[1] == '.') cout << buf+1 << endl;
- else return 0;
- }else
- cout << buf << endl;
- return 1;
- }
-
-